
<form enctype="multipart/form-data" method="post" action="/tourist/update_user_info/<{$user.uid}>">

    <h2 class="title">个人头像</h2>

    <div class="upload">
        <div class="img-wrap">
    <img id="imgId" <{if $user.userIcon=='' and $user.userGender=='m'}>src="/upload/upload/images/nousericon-m.png"
                    <{elseif $user.userIcon=='' and $user.userGender=='f'}>src="/upload/upload/images/nousericon-f.png"
                    <{elseif $user.userIcon=='' and $user.userGender==''}>src="/resource/www/imgs/default_tx.png"
                    <{else}>src="<{$user.userIcon}>"<{/if}> 
class="img">
        </div>
        <div class="content">
            <p class="text">清楚的脸部正面照对导游和游客了解彼此起着重大作用，请上传一张能清楚看到您脸部的照片。</p>
             <div class="file">
                 <!-- <input type="file" value="" id="userHeadImg" name="userIcon" onblur="submit_form()">请上传您的头像 -->
                 <input type="file" value="" id="userHeadImg" name="userIcon">请上传您的头像
             </div>
            <div class="img-right" style="top:20px;">
       <img src="/upload/upload/images/guide_info_upload_right.png">
       </div>
       <div class="img-wrong" style="top:-80px;">
       <img src="/upload/upload/images/guide_info_upload_wrong.png">
       </div> 

        </div>
    </div>

    <input type="hidden" name="uid" value="<{$uid}>">

    <h2 class="title">个人信息</h2>

    <div class="youkexinxi">
        <p class="tishi">温馨提示：为了便于哇吖对您的身份识别，保证旅行的安全，请填写真实姓名。</p>
        <label class="label">
            <span class="text">姓氏</span>
            <input type="text" name="userFamily" value="<{$user.userFamily}>" placeholder="例如：张"  class="shurk">
        </label>
        <label class="label">
            <span class="text">名字</span>
            <input type="text" name="userName" value="<{$user.userName}>"  placeholder="例如：三"  class="shurk">
        </label>
        <label class="label">
            <span class="text">性别</span>
           <select  name="userGender" id="" class="shurk">
                <option value="-1">请选择性别</option>
                <option value="m" <{if $user.userGender == 'm'}>selected<{/if}>>男</option>
                <option value="f" <{if $user.userGender == 'f'}>selected<{/if}>>女</option>
            </select>
        </label>
        <label class="label">
            <span class="text">年龄</span>
            <select name="userAge" id="" class="shurk">
                <option value="-1">请选择年龄</option>
                <option value="70后" <{if $user.userAge == '70后'}>selected<{/if}>>70后</option>
                <option value="80后" <{if $user.userAge == '80后'}>selected<{/if}>>80后</option>
                <option value="90后" <{if $user.userAge == '90后'}>selected<{/if}>>90后</option>
                <option value="00后" <{if $user.userAge == '00后'}>selected<{/if}>>00后</option>
            </select>
        </label>
        <label class="label">
            <span class="text">电话</span>
          <select name="code" style="width:100px;height:40px;border:1px solid #dcdcdc;margin-right:5px;text-align:center;">
  <option value="-1">国家区号</option>
                    <option value="+86" <{if $user.telCode=="+86"}>selected<{/if}> >中国(+86)</option>
                    <option value="+33" <{if $user.telCode=="+33"}>selected<{/if}> >法国(+33)</option>
  </select>
         <input type="text" name="userPhone" value="<{$user.userPhone}>"  placeholder="手机号码如果首位数字为0请去掉数字0"  class="shurk" style="width:290px;">
        </label>
        <input type="submit" class="submit" value="保存" onclick="return submit_form()">
    </div>

</form>

<script>

function submit_form(){

//    if($('input:file[name="userIcon"]').val() == ''){
//        layer.msg('头像不能为空');
//        return false;
//    }

    var oUserFamily = $("input:text[name='userFamily']").val();
    if (!$.trim(oUserFamily)) {
        layer.msg('姓氏不能为空');
        return false;
    }

    var oUserName = $("input:text[name='userName']").val();
    if (!$.trim(oUserName)) {
        layer.msg('名字不能为空');
        return false;
    }

    var oUserGender = $("select[name='userGender']").val();
    if (oUserGender == -1) {
        layer.msg('请选择性别');
        return false;
    }

    var oUserAge = $("select[name='userAge']").val();
    if (oUserAge == -1) {
        layer.msg('请选择年龄');
        return false;
    }

    var oCode = $("select[name='code']").val();
    if (oCode == -1) {
        layer.msg('请选择国家区号');
        return false;
    }
    var oUserPhone = $("input:text[name='userPhone']").val();
    var oUserPhoneReg =  /^[1-9][0-9]+$/;
    if (!$.trim(oUserPhone)) {
        layer.msg('请输入电话号码');
        return false;
    }
    if (!oUserPhoneReg.test($.trim(oUserPhone))) {
        layer.msg('请输入正确的电话号码');
        return false;
    }
}

</script>
<script>

$("#userHeadImg").change(function(event) {
    var file = $(event.target)[0].files[0];
    var src = URL.createObjectURL(file);
    if(file){
        $("#imgId").attr('src',src);
        //表示获取到了图片
    }else{
        //表示点击了取消
        $("#imgId").attr('src',"<{$user.userIcon}>");
    }
    //这里的src就是图片的地址，将它放在任意一个img标签的src属性里面
});

$(".info").addClass("active");
</script>
